<template>
  <div id="shop-item">
    <div class="item-selector">
      <check-button @click.native="checkClick" ref="check"
                    :isChecked="prudect.checked"></check-button>
    </div>
    <div class="item-img">
      <img :src="prudect.image" alt="商品图片">
    </div>
    <div class="item-info">
      <div class="item-title">{{ prudect.title }}</div>
      <div class="item-desc">{{ prudect.desc }}</div>
      <div class="info-bottom">
        <div class="item-price left">{{ prudect.price }}</div>
        <div class="item-price right">✖{{ prudect.count }}</div>
      </div>
    </div>
  </div>
</template>

<script>
import CheckButton from './CheckButton'

export default {
  name: 'CartLitsItem',
  props: {
    prudect: {
      type: Object,
      default () {
        return {}
      }
    }
  },
  data () {
    return {}
  },
  methods: {
    //接收内部选择按钮的点击
    checkClick () {
      this.prudect.checked = !this.prudect.checked

    }
  },
  components: {
    CheckButton
  },

}
</script>

<style scoped>
#shop-item {
  width: 95%;
  display: flex;
  font-size: 0;
  padding: 5px 10px 10px 5px;
  border-bottom: 1px solid #ccc;
}

.item-selector {
  width: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.item-title, .item-desc {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.item-img {
  padding: 5px;
}

.item-img img {
  width: 80px;
  height: 100px;
  display: flex;
  border-radius: 5px;
}

.item-info {
  font-size: 17px;
  color: #333;
  padding: 5px 10px;
  position: relative;
  overflow: hidden;
}

.item-info .item-desc {
  font-size: 14px;
  color: #666666;
  margin-top: 15px;
}

.info-bottom {
  margin-top: 10px;
  position: absolute;
  bottom: 10px;
  left: 10px;
  right: 10px;
}

.info-bottom .item-price {
  color: var(--color-tint);
}

.item-price right {
  float: left;
}

</style>
